package Java_网络编程.BS;

import com.sun.security.ntlm.Server;

import java.io.PrintStream;
import java.net.ServerSocket;
import java.net.Socket;

public class BSserver {
    public static void main(String[] args) {
        try {
            ServerSocket serverSocket = new ServerSocket(8002);
            while (true) {
                Socket accept = serverSocket.accept();
                new BSserverThread(accept).start();
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}


class BSserverThread extends Thread{

    private Socket socket;
    public  BSserverThread(Socket socket)
    {
        this.socket=socket;
    }

    @Override
    public void run() {
        try{
            PrintStream ps = new PrintStream(socket.getOutputStream());
            ps.println("HTTP/1.1 200 OK"); //响应数据的响应头数据
            ps.println("Content-Type:text/html;charset=UTF-8");  //响应数据类型
            ps.println();//必须换一行
            //以下开始响应真实数据
            ps.println("<span style=color:green;font-size:60px;>BS架构学习</span>");
            Thread.sleep(3000);
            ps.close();
        }catch (Exception e)
        {
            e.printStackTrace();
        }


        }

    }
